package com.zhao.dota.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhao.dota.model.UserHero;
import com.zhao.dota.vo.HeroVo;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserHeroMapper extends BaseMapper<UserHero> {

    @Select("<script>" +
            "select uh.user_id,h.* " +
            "  from user_hero uh " +
            "  left join hero h " +
            "    on uh.hero_id = h.id " +
            " where uh.league_id = #{leagueId} " +
            "   and uh.lost = 0" +
            "<if test='userId != null'>" +
            "   and uh.user_id = #{userId}" +
            "</if>" +
            "</script>")
    List<HeroVo> userHeroes(Integer leagueId, Integer userId);

}
